/**
 * Created by Administrator on 2019/1/22.
 */
function attendlogDis($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q){
    //打开 export 页面
    //打开导入 excel
    $scope.showImport = function(){
        $scope.bxType = "attendance";
        $("#fileUploadId").val("");
        //打开 上传页面
        $(".hidefile").show();
    }

    $scope.bxSelect = [
        {name:"考勤记录",code:"attendance"}
    ]

    $scope.bxType = "attendance";

    $scope.attendanceExcelImport = function(){
        if($scope.bxType && !angular.isUndefined($scope.bxType)){
            var form = new FormData();
            var file = document.getElementById("fileUploadId").files[0];
            if(!file){
                return;
            }
            form.append('file', file);
            form.append("bxType", $scope.bxType);
            var tish = layer.load(1);
            // CertusFormAjax.upload("attendanceExcel", form, function(res){
            //     layer.close(tish);
            //     // if(res.data.startsWith("success")){
            //     //     layer.msg("数据导入成功,成功导入"+res.data.replace("success--","")+"条");
            //     //     $(".hidefile").hide();
            //     //     return;
            //     // }else if(res.data.startsWith("failed")){
            //     //     layer.msg("第"+res.data.replace("failed","")+"行，数据有问题");
            //     //     $(".hidefile").hide();
            //     //     return;
            //     // }
            //
            //     $(".hidefile").hide();
            //
            //     dataInit.refresh(true);
            //     layer.msg(res.data);
            // });
            CertusFormAjax.upload("exportWechatExcel", form, function(res){
                layer.close(tish);
                // if(res.data.startsWith("success")){
                //     layer.msg("数据导入成功,成功导入"+res.data.replace("success--","")+"条");
                //     $(".hidefile").hide();
                //     return;
                // }else if(res.data.startsWith("failed")){
                //     layer.msg("第"+res.data.replace("failed","")+"行，数据有问题");
                //     $(".hidefile").hide();
                //     return;
                // }

                $(".hidefile").hide();

                dataInit.refresh(true);
                layer.msg(res.data);
            });
        }
    }

    //初始化 表格数据
    var dataInit = CertusJsonAjax.dataInit('attendanceRecordList',null,logGridColumns,'logDataGird','logGridToolBarContainer');

    //数据 查询方法
    $scope.searchData = function(){
        dataInit.parameters = {
            userName:$("#userNameId").val(),
            attendanceDate:$("#attendTime").val(),
            initStatus:$("#aaa1").val()
        }
        dataInit.refresh(true);
    }
}


function abnormalFunc($scope, $route, CertusFormAjax, CertusJsonAjax, $location, $http, $cookies, $routeParams, $q){

    $$scope = $scope;
    $CertusFormAjax = CertusFormAjax
    //更新按钮 触发 方法
    $scope.refreshAttendance = function(){
        var tish = layer.load(1);
        //请求 后台 刷新数据
        CertusFormAjax.ajax("refreshAttendance",{},function(res){
            if(res.data == "success"){
                layer.close(tish);
                dataInit.refresh(true);
                layer.msg("刷新成功");
            }
        })
    }

    //初始化 表格数据
    var dataInit = CertusJsonAjax.dataInit('unusualAttendanceRecordList',null,anlogGridColumns,'anlogDataGird','anlogGridToolBarContainer');
    dataInitPub = dataInit;
    //数据    查询方法
    $scope.searchData = function(){
        dataInit.parameters = {
            userName:$("#userNameId").val(),
            attendanceDate:$("#attendTime").val(),
            initStatus:$("#aaa1").val()
        }
        dataInit.refresh(true);
    }

    //发送邮件
    $scope.sendEmail = function(){
        CertusFormAjax.ajax("sendEmailAttendanceError",{},function(res){
            layer.msg(res.data);
        })
    }

    //导出
    $scope.exportExcelAttendance = function(){
        CertusFormAjax.download("exportExcelAttendance", "userName=" + $("#userNameId").val()+"&attendanceDate="+$("#attendTime").val()+"&initStatus="+$("#aaa1").val());
    }



}